﻿using System;
using System.Collections.Generic;
using System.Linq;
using ContentAppBase.Model.Bing;
using Windows.UI.Xaml.Data;

namespace ContentAppBase.Utils
{
    public class ItemTypeToItemSizeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is List<ResultBase>)
            {
                var firstItem = ((List<ResultBase>)value).FirstOrDefault();
                if (firstItem is ImageResult)
                {
                    if (parameter.ToString() == "Width")
                    {
                        return 120;
                    }
                    else if (parameter.ToString() == "Height")
                    {
                        return 120;
                    }
                }
                else if (firstItem is WebResult)
                {
                    if (parameter.ToString() == "Width")
                    {
                        return 360;
                    }
                    else if (parameter.ToString() == "Height")
                    {
                        return 120;
                    }
                }
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
